package com.wyzz.hr.pojo;

import org.apache.axis.utils.StringUtils;

import com.wyzz.hr.pojo.base.BaseAuthorityPos;
import com.wyzz.hr.util.MyTools;
import com.wyzz.hr.util.StringUtil;

public class AuthorityPos extends BaseAuthorityPos {

	public AuthorityPos() {
	}

	public AuthorityPos(String id) {
		super(id);
	}

	public AuthorityPos(String id, Position apPos, String apModule,
			String apAuthValidate) {
		super(id, apPos, apModule, apAuthValidate);
	}

	public void setApAuthValidateEncrypt(String deptId, String locId,
			String module) {
		String uuid = deptId;
		if (StringUtils.isEmpty(uuid))
			uuid = locId;
		String apAuthValidate = MyTools.vigenere(StringUtil
				.encodePassword((new StringBuilder()).append(uuid).append(
						module).toString()), MyTools.getUpKey(getId(),
				MyTools.STRING), MyTools.ENCRYPT_MODE);
		setApAuthValidate(apAuthValidate);
	}

	public boolean hasApAuthValidateDecrypt(String deptId, String locId,
			String module) {
		String uuid = deptId;
		if (StringUtils.isEmpty(uuid))
			uuid = locId;
		String apAuthValidate = MyTools.vigenere(StringUtil
				.encodePassword((new StringBuilder()).append(uuid).append(
						module).toString()), MyTools.getUpKey(getId(),
				MyTools.STRING), MyTools.ENCRYPT_MODE);
		return getApAuthValidate().equals(apAuthValidate);
	}

	private static final long serialVersionUID = 1L;
}
